<!-- 费用明细 -->
<template>
  <el-dialog
    title="费用明细"
    :visible.sync="dialogVisible"
    append-to-body
    width="60%"
  >
    <avue-crud
      :option="option"
      :table-loading="loading"
      :data="data"
      :page.sync="page"
      ref="crud"
      @current-change="currentChange"
      @size-change="sizeChange"
      @refresh-change="refreshChange"
    >
    </avue-crud>
    <span slot="footer" class="dialog-footer">
      <el-button @click="dialogVisible = false">关 闭</el-button>
    </span>
  </el-dialog>
</template>

<script>
import { getExpenseDetails } from "@/api/financial/index";

export default {
  data() {
    return {
      dialogVisible: false,
      loading: true,
      page: {
        pageSize: 10,
        currentPage: 1,
        total: 0,
      },
      option: {
        height: "auto",
        calcHeight: 200,
        tip: false,
        menu: false,
        searchShow: false,
        searchMenuSpan: 6,
        border: true,
        addBtn: false,
        editBtn: false,
        delBtn: false,
        columnBtn: false,
        column: [
          {
            label: "费用类型",
            prop: "chargeText",
          },
          {
            label: "运费",
            prop: "money",
          },
          {
            label: "币别",
            prop: "docCurrency",
          },
        ],
      },
      data: [],
      id: "",
    };
  },
  components: {},
  computed: {},
  methods: {
    currentChange(currentPage) {
      this.page.currentPage = currentPage;
      this.getList(this.page);
    },
    sizeChange(pageSize) {
      this.page.pageSize = pageSize;
      this.getList(this.page);
    },
    refreshChange() {
      this.getList(this.page);
    },
    open(id) {
      this.dialogVisible = true;
      this.id = id;
      this.getList(this.page);
    },
    getList(page) {
      let query = {
        id: this.id,
      };
      this.loading = true;
      getExpenseDetails(page.currentPage, page.pageSize, query).then((res) => {
        const data = res.data.data;
        this.page.total = data.total;
        this.data = data.records;
        this.loading = false;
      });
    },
  },
};
</script>

<style></style>
